package com.design.patterns.list.singleton;

/**
 * 单例模式：饿汉式方式一，静态成员变量
 * @author Wangzhiwen
 */
public class SingletonA {

    public static void main(String[] args) {

        Singleton instanceA = Singleton.getInstance();
        Singleton instanceB = Singleton.getInstance();
        System.out.println("单例模式："+ (instanceA == instanceB));
        System.out.println("hashCode："+ (instanceA.hashCode() == instanceB.hashCode()));
    }

}

class Singleton{

    /**
     * 私有化构造方法
     */
    private Singleton(){

    }

    private static final Singleton SINGLETON = new Singleton();

    public static Singleton getInstance(){
        return SINGLETON;
    }

}
